#include "git-annotated-commit.h"

#include <git2/annotated_commit.h>

namespace git
{

AnnotatedCommit::AnnotatedCommit(git_annotated_commit *ptr)
    : ptr_(ptr) {
}

AnnotatedCommit::AnnotatedCommit(AnnotatedCommit &&b)
    : ptr_(b.ptr_) {

    b.ptr_ = nullptr;
}

AnnotatedCommit::~AnnotatedCommit() {
    if (ptr_) {
        git_annotated_commit_free(ptr_);
        ptr_ = nullptr;
    }
}

AnnotatedCommit &AnnotatedCommit::operator=(AnnotatedCommit &&b) {
    if (this != &b && ptr_ != b.ptr_) {
        if (ptr_) {
            git_annotated_commit_free(ptr_);
        }
        ptr_ = b.ptr_;
        b.ptr_ = nullptr;
    }
    return *this;
}



}
